- main_toolbar do |t|
  = t.edit resource if resource.updateable?
  = dropdown_menu_button(:export.ta, icon: :download) do |d|
    - export_params = params.slice(:states)
    - d.item :export_as_odt.tl, params: export_params.merge(format: :odt)
    - d.item :export_as_pdf.tl, html_options: { data: { no_turbolink: true } }, params: export_params.merge(format: :pdf)
  = t.destroy
  - if current_user.can?(:write, :incoming_deliveries) && resource.can_generate_parcel?
    = t.new(params: { controller: :receptions, purchase_order_ids: resource.id, nature: :incoming, mode: 'prefilled' }, label: :generate_parcel.tl)

= main_state_bar(resource)

= main_informations attachment: true do
  = attributes_list do |l|
    - l.attribute :supplier, label: :label, url: true
    - l.attribute :number
    - l.attribute :reference_number unless resource.reference_number.blank?
    - l.attribute :state
    - l.attribute :responsible, label: :full_name
    - l.attribute :created_at
    - l.attribute :ordered_at
    - l.attribute :payment_delay, label: :name
    - l.attribute :currency unless resource.currency == Preference[:currency]
    - l.attribute :description unless resource.description.blank?
    - l.attribute :delivery_address, label: :coordinate

= cobbles do |c|

  - c.cobble :items, title: PurchaseOrder.human_attribute_name(:items) do
    = cobble_list :items do
      %tr.total
        %th{ colspan: 8 }= :total.tl
        %td= "#{resource.pretax_amount.l(currency: resource.currency)} #{:pretax.tl}"
        %td= "#{resource.amount.l(currency: resource.currency)} #{:including_vat.tl}"
